package com.dhcc.entity;

import lombok.Data;
import java.net.URLEncoder;

@Data
public class GatewayRequest <T>{
    /**
     * 时间戳
     */
    private  String timeStamp;
    /**
     * 编码
     */
    private  String charset ;
    /**
     * 渠道编码
     */
    private  String chnlCode ;
    /**
     * token
     */
    private  String access_token;
    /**
     * 服务编码
     */
    private  String serviceCode ;
    /**
     * 服务细分编码
     */
    private String svcSubCode;
    /**
     * 加密算法（sm4）
     */
    private  String encryptAlgo;
    /**
     * 请求id
     */
    private  String requestId;
    /**
     * 生成的签名串
     */
    private  String sign;
    /**
     * 机构号
     */
    private  String txBrNo;
    /**
     * 请求sm4加密的密文
     * @return
     */
    private T requestData;


    /**
     * 用sm2加密的sm4对称密钥
     */
    private  String encodeKey;

    /**
     * 版本
     */
    private  String version ;
    
    public String toUrlString() {
    	StringBuffer buffer = new StringBuffer();
    	if (this.timeStamp != null)buffer.append("timeStamp=" + this.timeStamp);
    	if (this.charset != null)buffer.append("&charset=" + this.charset);
    	if (this.chnlCode != null)buffer.append("&chnlCode=" + this.chnlCode);
    	if (this.access_token != null)buffer.append("&access_token=" + this.access_token);
    	if (this.serviceCode != null)buffer.append("&serviceCode=" + this.serviceCode);
    	if (this.svcSubCode != null)buffer.append("&svcSubCode=" + this.svcSubCode);
    	if (this.encryptAlgo != null)buffer.append("&encryptAlgo=" + this.encryptAlgo);
    	if (this.requestId != null)buffer.append("&requestId=" + this.requestId);
    	if (this.sign != null)buffer.append("&sign=" + this.sign);
    	if (this.txBrNo != null)buffer.append("&txBrNo=" + this.txBrNo);
    	if (this.encodeKey != null)buffer.append("&encodeKey=" + this.encodeKey);
    	if (this.version != null)buffer.append("&version=" + this.version);
    	if (this.requestData != null)buffer.append("&requestData=" + this.requestData);
    	return URLEncoder.encode(buffer.toString());
    }
}
